home *** CD-ROM | disk | FTP | other *** search
- unit StartU;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls,
- Forms, Dialogs;
-
- type
- TForm1 = class(TForm)
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- {$ifdef Win32}
- procedure DoRestore(Sender: TObject);
- {$endif}
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- {$ifdef Win32}
- procedure TForm1.DoRestore(Sender: TObject);
- begin
- Application.ShowMainForm := True;
- { Restore application }
- Perform(wm_SysCommand, sc_Restore, 0);
- { This is needed to ensure all components draw properly }
- Show;
- { Disconnect the event handler so this code will not be called again }
- Application.OnRestore := nil;
- end;
- {$endif}
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- if WindowState = wsNormal then
- case CmdShow of
- sw_ShowNormal, sw_ShowNoActivate, sw_Show,
- sw_ShowNA, sw_Restore: WindowState := wsNormal;
- sw_ShowMinimized, sw_Minimize,
- sw_ShowMinNoActive: WindowState := wsMinimized;
- sw_ShowMaximized: WindowState := wsMaximized;
- end;
- {$ifdef Win32}
- if WindowState = wsMinimized then
- begin
- Application.ShowMainForm := False;
- Application.OnRestore := DoRestore;
- Application.Minimize;
- end;
- {$endif}
- end;
-
- {$ifdef Win32}
- var
- StartupInfo : TStartupInfo;
-
- initialization
- { Set up CmdShow correctly to workaround the fact that }
- { Delphi hardwires it to a value 10 (sw_ShowNormal) }
- GetStartupInfo(StartupInfo);
- CmdShow := StartupInfo.wShowWindow;
- {$endif}
- end.
-